package com.zjj.concurrent.feature.automic;

/**
 * @author zhanglei.zjj
 * @description 并发编程原子性问题分析
 *
 * @date 2023/5/13 18:25
 */
public class AtomicTest {
    private static int counter = 0;

    public static void main(String[] args) {

        for (int i = 0; i < 10; i++) {
            Thread thread = new Thread(() -> {
                for (int j = 0; j < 10000; j++) {
                    counter++;
                }

            });
            thread.start();
        }

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(counter);
    }
}